const express = require('express');
const app = express();

const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

// 配置cors
const cors = require('cors');
app.use(cors());


// 配置解析token中间件
const expressJWT = require('express-jwt');
const config = require('./config');
app.use(expressJWT({ secret: config.jwtSecretKey, algorithms: ['HS256'] }).unless({
    path: ['/login', '/register']
}));

const router = require('./router/user');
app.use(router);

app.listen(3007, () => {
    console.log('api server running at http://127.0.0.1:3007');
});